package com.chenglin.dogapplication

import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.adapter_item.view.*


/**
 *
 * @Author:         程林
 * @CreateDate:     2021/9/24$ 15:00$
 */
class DogAdapter(var context: Context) :
    RecyclerView.Adapter<DogAdapter.MyHolder>() {

    lateinit var list : ArrayList<KeyValueBean>

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyHolder {
        var itemView = LayoutInflater.from(context).inflate(R.layout.adapter_item, parent, false)
        return MyHolder(itemView)
    }

    fun getOldList(): ArrayList<KeyValueBean> {
        return list
    }

    fun setData(newList: ArrayList<KeyValueBean>){

        this.list = newList
    }

    override fun onBindViewHolder(holder: MyHolder, position: Int) {
        holder.itemView.tv_id.text = list[position].id
        holder.itemView.name.text =list[position].name



    }

    override fun getItemCount(): Int {
        Log.e("list的长度","${list.size}")
        return list.size
    }


    class MyHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

    }

}